package com.runa.rccprotocol.dto.huanxiang;

import com.runa.protocol.dto.DtuReportAck;
import com.runa.protocol.util.ByteUtil;

/**
 * @author diandian
 * @Date 2022/5/12 20:25
 */
public class HuanXiangReportAck extends DtuReportAck {

    public HuanXiangReportAck(String netEquNo) {
        this.data = new byte[20];
        data[0] = (byte) 0xC0;
        data[1] = 0x22;
        ByteUtil.tenstringToBcd(data, netEquNo, 2, true);
        data[8] = 0x01;
        data[9] = 0x00;
        data[10] = 0x00;
        data[11] = 0x00;
        data[12] = ByteUtil.sum(data, 1, 11);
        data[13] = (byte) 0xD0;
    }


    public static void main(String[] args) {
        String s = "C02103004022063501000040153836353234323035363430313137393436303034383634353930343837393839383630343636313231394331383332393739240790821F8F0302150C08060092D0";
        byte[] bytes = ByteUtil.hexStringToByte(s);
        byte sum = ByteUtil.sum(bytes, 1, bytes.length - 3);
        byte[] bytes1 = new byte[]{sum};
        System.out.println(ByteUtil.byteToHexString(bytes1));

    }
}